#!/bin/bash

# install fabric docker image
echo -e "\e[1;32m正在安装Fabric镜像 \e[0m"
# check install-fabric.sh
if [ ! -f "install-fabric.sh" ]; then
  echo "install-fabric.sh not found!"
  exit 1
fi
./install-fabric.sh -f 2.2.7 docker
echo -e "\e[1;32mFabric镜像安装完成\e[0m"

# start network, 
# this script will start the test-network, create channel, and deploy chaincode
echo -e "\e[1;33m正在启动网络 \e[0m"
# check fabric-samples
if [ ! -d "fabric-samples" ]; then
  echo "fabric-samples not found!"
  exit 1
fi
cd fabric-samples
# check ./start-network.sh
if [ ! -f "start-network.sh" ]; then
  echo "start-network.sh not found!"
  exit 1
fi
./start-network.sh
echo -e "\e[1;33m网络启动完成\e[0m"

